<template>
  <div class="mod-log">
    <el-table
      :data="dataList"

      style="width: 100%">
      <el-table-column
        prop="id"
        header-align="center"
        align="center"
        width="80"
        label="ID">
      </el-table-column>
      <el-table-column
        prop="errorClass"
        header-align="center"
        align="center"
        label="异常类名">
      </el-table-column>
      <el-table-column
        prop="errorDesc"
        header-align="center"
        align="center"
        label="异常类型">
      </el-table-column>
      <el-table-column
        prop="errorCount"
        header-align="center"
        align="center"
        label="异常发生次数">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="errorTypeUpdateHandle(scope.row.id,scope.row.errorClass,scope.row.errorDesc)">设置类型说明</el-button>
        </template>
      </el-table-column>
    </el-table>
    <error-type-set v-if="errorTypeUpdateVisible" ref="errorTypeSet" @refreshDataList="getDataList"></error-type-set>
  </div>
 </template>

<script>
  import ErrorTypeSet from './error-type-set'
  export default {
    data () {
      return {
        dataList: [],
        pageIndex: 1,
        selectionDataList: [],
        errorTypeUpdateVisible:false
      }
    },
    components: {
      ErrorTypeSet
    },
    created () {
      this.getDataList()
    },
    methods: {
      errorTypeUpdateHandle (id,errorClass,errorDesc) {
        this.errorTypeUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.errorTypeSet.init(id,errorClass,errorDesc)
        })
      },
      // 获取数据列表
      getDataList () {
        this.$http({
          url: this.$http.adornUrl('admin/api/sys/log/error/findLogErrorTypeList'),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 200) {
            this.dataList = data.data
          } else {
            this.dataList = []
          }
        })
      }

    }
  }
</script>
